<template>
  <tbody>
    <tr v-for="(item, index) in value" :key="index">
      <td>
        <input
          type="checkbox"
          :value="item.checked"
          :checked="(item.checked = !item.checked)"
        />
      </td>
      <td>{{ item.name }}</td>
      <td>{{ item.price }}</td>
      <td>
        <button @click="item.num--">-</button>
        {{ item.num }}
        <button @click="item.num++">+</button>
      </td>
      <td>{{ item.price * item.num }}</td>
      <td><button>删除</button></td>
    </tr>
  </tbody>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    value: {
      type: Array,
    },
  },
  methods: {},
  computed: {
    allMoney() {
      //   return this.$emit('allMoney',)
      return this.value.reduce((dev, item) => dev + item.price * item.num, 0);
    },
  },
};
</script>

<style scoped></style>
